import { request } from "@/api/service";
import { BUTTON_STATUS_NUMBER } from "@/config/button";
import { urlPrefix as complaintsPrefix } from "./api";


export const crudOptions = vm => {
  return {
    pageOptions: {
      compact: true,
      export: {
        local: true,//本地导出，false为服务端导出
      },
    },
    options: {
      tableType: "vxe-table",
      rowKey: true, // 必须设置，true or false
      rowId: "id",
      height: "100%", // 表格高度100%, 使用toolbar必须设置
      highlightCurrentRow: false
    },
    rowHandle: {
      width: 140,
      view: {
        thin: true,
        text: "",
        disabled() {
          return !vm.hasPermissions("Retrieve");
        }
      },
      edit: {
        thin: true,
        text: "",
        disabled() {
          return !vm.hasPermissions("Update");
        }
      },
      remove: {
        thin: true,
        text: "",
        disabled() {
          return !vm.hasPermissions("Delete");
        }
      }
    },
    indexRow: {
      // 或者直接传true,不显示title，不居中
      title: "序号",
      align: "center",
      width: 100
    },
    viewOptions: {
      componentType: "form"
    },
    formOptions: {
      defaultSpan: 24, // 默认的表单 span
      width: "35%"
    },
    columns: [{
      title: "ID",
      key: "id",
      show: false,
      disabled: true,
      width: 90,
      form: {
        disabled: true
      }
    },
    {
      title: "月报期数",
      key: "月报期数",
      width: 100,
      sortable: true,
      treeNode: true,

      type: "number",
      form: {
        editDisabled: true,
        rules: [
          // 表单校验规则
          { required: true, message: "月报期数必填" }
        ],
        component: {
          props: {
            clearable: true
          },
          placeholder: "请输入月报期数"
        },
        itemProps: {
          class: { yxtInput: true }
        }
      }
    },
    {
      title: "产品分类",
      key: "产品分类",
      width: 100,
      sortable: true,
      treeNode: true,

      type: "input",
      search: {
        component: {
          props: {
            clearable: true
          }
        }
      },
      form: {
        editDisabled: true,
        rules: [
          // 表单校验规则
          { required: true, message: "产品分类必填" }
        ],
        component: {
          props: {
            clearable: true
          },
          placeholder: "请输入产品分类"
        },
        itemProps: {
          class: { yxtInput: true }
        }
      }
    },
    {
      title: "日期",
      key: "日期",
      width: 200,
      sortable: true,
      treeNode: true,

      type: "date",
      search: {
        component: {
          props: {
            clearable: true
          }
        }
      },
      form: {
        editDisabled: true,
        rules: [
          // 表单校验规则
          { required: true, message: "日期必填" }
        ],
        component: {
          props: {
            clearable: true
          },
          placeholder: "请输入日期"
        },
        itemProps: {
          class: { yxtInput: true }
        }
      }
    },
    {
      title: "召回数量",
      key: "召回数量",
      width: 100,
      sortable: true,
      treeNode: true,

      type: "number",
      form: {
        editDisabled: true,
        rules: [
          // 表单校验规则
          { required: true, message: "召回数量必填" }
        ],
        component: {
          props: {
            clearable: true
          },
          placeholder: "请输入召回数量"
        },
        itemProps: {
          class: { yxtInput: true }
        }
      }
    },
    {
      title: "产品名称",
      key: "产品名称",
      width: 100,
      sortable: true,
      treeNode: true,

      type: "input",
      search: {
        component: {
          props: {
            clearable: true
          }
        }
      },
      form: {
        editDisabled: true,
        rules: [
          // 表单校验规则
          { required: true, message: "产品名称必填" }
        ],
        component: {
          props: {
            clearable: true
          },
          placeholder: "请输入产品名称"
        },
        itemProps: {
          class: { yxtInput: true }
        }
      }
    },
    {
      title: "标题",
      key: "标题",
      width: 200,
      sortable: true,
      treeNode: true,

      type: "input",
      form: {
        editDisabled: true,
        rules: [
          // 表单校验规则
          { required: true, message: "标题必填" }
        ],
        component: {
          props: {
            clearable: true
          },
          placeholder: "请输入标题"
        },
        itemProps: {
          class: { yxtInput: true }
        }
      }
    },
    {
      title: "召回原因",
      key: "召回原因",
      width: 300,
      sortable: true,
      treeNode: true,

      type: "input",
      form: {
        editDisabled: true,
        rules: [
          // 表单校验规则
          { required: true, message: "召回原因必填" }
        ],
        component: {
          props: {
            clearable: true
          },
          placeholder: "请输入召回原因"
        },
        itemProps: {
          class: { yxtInput: true }
        }
      }
    },
    {
      title: "危害源",
      key: "危害源",
      width: 200,
      sortable: true,
      treeNode: true,

      type: "input",
      form: {
        editDisabled: true,
        rules: [
          // 表单校验规则
          { required: true, message: "危害源必填" }
        ],
        component: {
          props: {
            clearable: true
          },
          placeholder: "请输入危害源"
        },
        itemProps: {
          class: { yxtInput: true }
        }
      }
    },
    {
      title: "危害情况",
      key: "危害情况",
      width: 100,
      sortable: true,
      treeNode: true,

      type: "input",
      form: {
        editDisabled: true,
        rules: [
          // 表单校验规则
          { required: true, message: "危害情况必填" }
        ],
        component: {
          props: {
            clearable: true
          },
          placeholder: "请输入危害情况"
        },
        itemProps: {
          class: { yxtInput: true }
        }
      }
    },
    {
      title: "区域",
      key: "区域",
      width: 100,
      sortable: true,

      search: {
        disabled: false,
        component: {
          props: {
            clearable: true
          }
        }
      },

      type: "select",
      form: {
        editDisabled: true,
        rules: [
          // 表单校验规则
          { required: true, message: "区域必填" }
        ],
        component: {
          props: {
            clearable: true
          },
          placeholder: "请输入区域"
        },
        itemProps: {
          class: { yxtInput: true }
        }
      },
      dict: {  //本地数据字典
        data: [
          { value: '思明区', label: '思明区' },
          { value: '湖里区', label: '湖里区' },
          { value: '集美区', label: '集美区' },
          { value: '翔安区', label: '翔安区' },
          { value: '海沧区', label: '海沧区' },
          { value: '同安区', label: '同安区' }
        ]
      }
    },
    {
      title: "链接",
      key: "链接",
      width: 400,
      sortable: true,
      treeNode: true,

      type: "input",
      form: {
        editDisabled: true,
        rules: [
          // 表单校验规则
          { required: true, message: "链接必填" }
        ],
        component: {
          props: {
            clearable: true
          },
          placeholder: "请输入链接"
        },
        itemProps: {
          class: { yxtInput: true }
        }
      }
    },
    ].concat(vm.commonEndColumns())
  };
};
